package com.example.zuoye.service.impl;

import com.example.zuoye.dao.UserDAO;
import com.example.zuoye.entity.User;
import com.example.zuoye.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDAO userDAO;

    @Override
    public String findUserNameByUserName(String username) {
        return userDAO.findUserNameByUserName(username);
    }

    @Override
    public int insertUser(User user) {
        return userDAO.insertUserInfo(user);
    }

    @Override
    public User checkByUP(String username, String password) throws Exception {
        if (username == null || password == null){
//            throw new Exception("用户名和密码不能为空");
            System.out.println("用户名和密码不能为空");
        }
        User user = userDAO.checkByUP(username, password);
        if (user == null){
//            throw new Exception("用户不存在");
            System.out.println("用户不存在");
        }
        return user;
    }
}
